<template>
	<view class="container">
		
		
		<view class="jx-mybg-box">
			<image :src="bg_url" class="jx-my-bg"></image>
			
			<view class="goods-info" @click="openUrl('/pages/goods/detail?proId='+goods_id)">
				<image :src="goods.goods_cover" lazy-load="true" class="jx-goods-img"></image>
				<view class="goods-desc">
					<view class="ellipsis-2" style="font-size: 9pt;">{{goods.goods_name}}</view>
					<view>￥{{goods.goods_price}}</view>
					<view style="text-decoration: underline;color: rgb(255,166,0);text-align: right;font-size: 9pt;">查看详情</view>
				</view>
			</view>
			
			
			<view class="er-code" v-if="clerkData.status != 1">
				<view class="code_logo">
					<image :src="clerkData.image" style="border: 1rpx solid #337766;"></image>
					<text style="font-size: 9pt;">核销码：{{clerkData.code}}</text>
					<text style="font-size: 9pt;">{{clerkData.use_num}}/{{clerkData.clerk_num}}</text>
				</view>
			</view>
			
			<view v-if="clerkData.status == 1" style="padding: 50rpx 0;text-align: center;font-weight: 600;font-size: 12pt">当前商品已核销完毕~</view>
			
			<info :params="mch"></info>
			
		</view>
		
	</view>
</template>

<script>
	import info from '@/components/shop/info';
	export default {
		components:{
			info
		},
		data(){
			return {
				goods_id:'',
				bg_url:'',
				mch:{
					store_id: "",
					mch_id: "",
					name: "",
					score: 5,
					cover_url: "https://h5-mingyuanriji.cn/web/static/header-logo.png",
				},
				goods:{
					goods_cover:'',
					goods_name:'',
					goods_price:''
				},
				clerkData:{
					code:'',
					image:'',
					clerk_num:1,
					use_num:0
				}
			}
		},
		onLoad(opt){
			this.bg_url = this.globalSet('imgUrl');
			this.goods_id = opt.goods_id ?? 0;
			this.getDetail()
		},
		methods:{
			back(){
				this.navBack();
			},
			async getDetail(){
				let goods_id = this.goods_id;
				let res = await this.$http.request({
					url: this.$api.localLife.stockGoodsDetail,
					method: 'get',
					data:{goods_id},
					showLoading: true,
				});
				let data = res.data;
				this.mch = data.mch;
				this.mch.store_id = data.mch.id;
				this.goods = data.goods;
				this.clerkData = data.clerk_data;
			},
			openUrl(url){
				uni.navigateTo({url})
			}
		}
	}
</script>

<style lang="scss">
	.jx-mybg-box {
		width: 100%;
	}
	.jx-my-bg {
		width: 100%;
		height: 340rpx;
		z-index: 1;
	}
	.goods-info{
		width: 85vw;
		margin: -28vw auto 0;
		display: flex;
		background-color: #FFFFFF;
		padding: 20rpx;
		border-radius: 20rpx;
		position: relative;
		z-index: 99;
	}
	.goods-desc{
		width: 55vw;
		margin-left: 20rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-around;
	}
	.jx-goods-img{
		width: 20vw;
		height: 20vw;
	}
	.ellipsis-2{
		overflow: hidden;
		display:-webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
	}
	.ellipsis-1{
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	
	.er-code{
		width: 100%;
		height: 500rpx;
		box-shadow: 0 0 1px rgba(242, 242, 242, 0.8);
		background: #fff;
		margin-top: 40rpx;
	}
	.code_logo{
		width: 400rpx;
		height: 400rpx;
		margin: 0 auto;
		position: relative;
	}
	.code_logo image{
		width: 400rpx;
		height: 400rpx;
		display: block;
	}
	.code_logo text{
		display: block;
		width: 100%;
		height: 50rpx;
		text-align: center;
		line-height: 50rpx;
		background: #3F536E;
		color: #fff;
	}
</style>